import { round } from 'mathjs';
export default function fetchTransactionStatisticsData(cycle: string) {
  const randomNum = Math.random() - 0.5;
  let day = 1;
  switch (cycle) {
    case 'today':
      day = 1;
      break;
    case 'week':
      day = 7;
      break;
    case 'month':
      day = 31;
      break;
    case 'year':
      day = 365;
      break;
  }

  let openAccountCount = Math.ceil(157 * day * (1 + randomNum));
  let openAccountAmount = round(0 * day * (1 + randomNum), 2);
  let withdrawalCount = Math.ceil(1486 * day * (1 + randomNum));
  let withdrawalAmount = round(689.26 * day * (1 + randomNum), 2);
  let depositCount = Math.ceil(856 * day * (1 + randomNum));
  let depositAmount = round(354.89 * day * (1 + randomNum), 2);
  let transferAccountsCount = Math.ceil(1896 * day * (1 + randomNum));
  let transferAccountsAmount = round(568.84 * day * (1 + randomNum), 2);
  let currentTermCount = Math.ceil(359 * day * (1 + randomNum));
  let currentTermAmount = round(576.15 * day * (1 + randomNum), 2);
  let timeTenewalCurrentCount = Math.ceil(249 * day * (1 + randomNum));
  let timeTenewalCurrentAmount = round(365.24 * day * (1 + randomNum), 2);
  let financeCount = Math.ceil(165 * day * (1 + randomNum));
  let financeAmount = round(612.93 * day * (1 + randomNum), 2);
  let payTheFeesCount = Math.ceil(149 * day * (1 + randomNum));
  let payTheFeesAmount = round(9.56 * day * (1 + randomNum), 2);
  let otherCount = Math.ceil(5642 * day * (1 + randomNum));
  let otherAmount = round(0 * day * (1 + randomNum), 2);
  let allCount =
    openAccountCount +
    withdrawalCount +
    depositCount +
    transferAccountsCount +
    currentTermCount +
    timeTenewalCurrentCount +
    financeCount +
    payTheFeesCount +
    otherCount;
  let allAmount = round(
    openAccountAmount +
      withdrawalAmount +
      depositAmount +
      transferAccountsAmount +
      currentTermAmount +
      timeTenewalCurrentAmount +
      financeAmount +
      payTheFeesAmount +
      otherAmount,
    2,
  );

  return [
    {
      type: '全部交易',
      count: allCount,
      amount: allAmount,
    },
    {
      type: '开户',
      count: openAccountCount,
      amount: openAccountAmount,
    },
    {
      type: '取款',
      count: withdrawalCount,
      amount: withdrawalAmount,
    },
    {
      type: '存款',
      count: depositCount,
      amount: depositAmount,
    },
    {
      type: '转账',
      count: transferAccountsCount,
      amount: transferAccountsAmount,
    },
    {
      type: '定期转活期',
      count: timeTenewalCurrentCount,
      amount: timeTenewalCurrentAmount,
    },
    {
      type: '活期转定期',
      count: currentTermCount,
      amount: currentTermAmount,
    },
    {
      type: '理财',
      count: financeCount,
      amount: financeAmount,
    },
    {
      type: '代缴费',
      count: payTheFeesCount,
      amount: payTheFeesAmount,
    },
    {
      type: '其他',
      count: otherCount,
      amount: otherAmount,
    },
  ];
}
